<%= form_for(@operation) do |f| %>
    <% if @operation.errors.any? %>
        <div id="error_explanation">
          <h2><%= pluralize(@operation.errors.count, "error") %> prohibited this operation from being saved:</h2>

          <ul>
            <% @operation.errors.full_messages.each do |msg| %>
                <li><%= msg %></li>
            <% end %>
          </ul>
        </div>
    <% end %>

    <table>
      <tr>
        <td><%= f.label :name %></td>
        <td><%= f.select :operation_type, [["+", "+"], ["-", "-"], ["~", "~"]] %></td>
      </tr>

      <tr>
        <td valign="top">Money</td>
        <td>
          <table class="amounts">
            <thead>
            <tr>
              <th></th>
              <th></th>
              <th></th>
            </tr>
            </thead>

            <%= f.fields_for :amount_changes do |builder| %>
                <tr class="amount" style="padding-left:30px;">
                  <%= render 'amount_change_fields', :f => builder %>
                </tr>
            <% end %>

            <%= f.fields_for :amount_changes, AmountChange.new, :child_index => "new_amount" do |builder| %>
                <tr class="template" style="padding-left:30px; display:none">
                  <%= render 'amount_change_fields', :f => builder %>
                </tr>
            <% end %>
          </table>

          <%= link_to_function "add", "addAmount()" %>
        </td>
      </tr>
    </table>


    <div class="actions">
      <%= f.submit %>
    </div>
<% end %>
